import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],

  server: {
    host: "0.0.0.0",
    port: 8081, //配置端口好
    hmr: true, //开启热更新
    open: true, //启动在浏览器里打开
    proxy: {
      "/api": {
        target: "http://localhost:8080/", //接口地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },

  resolve: {
    alias: [
      {
        find: "@",
        replacement: resolve(__dirname, "src"),
      },
    ],
  },
  define: {
    "process.env": {
      // BASE_API: "http://192.168.31.70:8081",
      BASE_API: "http://localhost:8080",
    },
  },
});
